#include <iostream>
using namespace std;

const int kMaxN = 1e5 + 10;

int a[kMaxN], sum[kMaxN];

int GetSum(int l, int r) {
  return sum[r] - sum[l - 1];
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;

  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1] + a[i];
  }
  cin >> m; 
  for (int i = 0; i < m; i++) {
    int l, r;

    cin >> l >> r;
    cout << GetSum(l, r) << "\n";
  }
  return 0;
}
